

/// Log Util.
class LogUtil {

  static const String _TAG = " LogUtil >>";

  //日志开关
  static const DEBUG_LOG_ON = true;

  static void e(Object object, {String tag}) {
    _printLog(tag, 'e >>> ', object);
  }

  static void d(Object object, {String tag}) {
    _printLog(tag, 'd >>> ', object);
  }

  static void _printLog(String tag, String type, Object object) {

    if(DEBUG_LOG_ON != true) return;

    String da = object?.toString() ?? "null";
    String _tag = (tag == null || tag.isEmpty) ? _TAG : tag;
    while (da.isNotEmpty) {
      if (da.length > 512) {
        print("$_tag $type ${da.substring(0, 512)}");
        da = da.substring(512, da.length);
      } else {
        print("$_tag $type $da");
        da = "";
      }
    }
  }
}